<template>
  <div class="passchange">
      <a-form-model :model="form" :label-col="labelCol" :wrapper-col="wrapperCol">
            <a-form-model-item label="原密码">
                <a-input type="password" v-model="form.old_password" />
            </a-form-model-item>
            <a-form-model-item label="新密码">
                <a-input type="password" v-model="form.new_password" />
            </a-form-model-item>
            <a-form-model-item label="再次确认新密码">
                <a-input type="password" v-model="form.newpasswordd" />
            </a-form-model-item>
            <a-form-model-item :wrapper-col="{ span: 14, offset: 4 }">
                <a-button type="primary" @click="changepass">
                    提交
                </a-button>
            </a-form-model-item>
        </a-form-model>
  </div>
</template>

<script>
import axios from '../../utils/axios'
export default {
    data() {
        return {
            labelCol: { span: 4 },
            wrapperCol: { span: 14 },
            form:{
                old_password:'',
                new_password:'',
                newpasswordd:''
            }
        }
    },
    methods:{
        changepass(){
            if(this.form.new_password!=this.form.newpasswordd){
                this.$message.error('新密码不一致')
                return
            }
            axios.post('/trains/update_password/',this.form).then(res=>{
                if(res.error=='原密码错误'){
                    this.$message.error('原密码错误')
                }else{
                    this.$message.success('修改成功')
                    this.form={}
                }
            })
        }
    }
}
</script>

<style>

</style>